#include "recordinfomodel.h"
 RecordInfoModel::RecordInfoModel(QObject *parent)
     : QAbstractListModel(parent)
 {
     QHash<int, QByteArray> roles;
     roles[NameRole] = "name";
     roles[ContextRole] = "context";
     setRoleNames(roles);
 }

 void RecordInfoModel::addRecordInfo(const recordInfo &recordinfo)
 {
     beginInsertRows(QModelIndex(), rowCount(), rowCount());
     m_recordInfos << recordinfo;
     endInsertRows();
 }

 int RecordInfoModel::rowCount(const QModelIndex & parent) const {
     return m_recordInfos.count();
 }

 QVariant RecordInfoModel::data(const QModelIndex & index, int role) const {
     if (index.row() < 0 || index.row() > m_recordInfos.count())
         return QVariant();
     const recordInfo &recordinfo = m_recordInfos[index.row()];
     if (role == NameRole)
         return recordinfo.getName();
     else if (role == ContextRole)
         return recordinfo.getContent();
     return QVariant();
 }
